package com.rykj.ext

import com.google.gson.Gson
import com.rykj.util.StringUtil
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody


fun String?.toyyyyMMddHHmm(): String {
    return StringUtil.getTimeStrFromFormatStr("yyyy-MM-dd HH:mm", this)
}

fun String?.toYMD(): String {
    return StringUtil.getTimeStrFromFormatStr("yyyy-MM-dd", this)
}

fun String?.toFormatStr(format:String): String {
    return StringUtil.getTimeStrFromFormatStr(format, this)
}


fun Any.toGsonBody(): RequestBody {
    return RequestBody.create("application/json".toMediaTypeOrNull(), Gson().toJson(this))
}